| Fully Qualified Name: | CodeIgniter\HTTP\IncomingRequest |
| Extends: | Request |
Class IncomingRequest
Represents an incoming, getServer-side HTTP request.
Per the HTTP specification, this interface includes properties for each of the following:
Additionally, it encapsulates all data as it has arrived to the application from the CGI and/or PHP environment, including:
| Name | Description | Defined By |
|---|---|---|
| __construct() | Constructor | IncomingRequest |
| appendBody() | Appends data to the body of the current message. | Message |
| appendHeader() | Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess) | Message |
| detectLocale() | Handles setting up the locale, perhaps auto-detecting through content negotiation. | IncomingRequest |
| detectPath() | Based on the URIProtocol Config setting, will attempt to detect the path portion of the current URI. | IncomingRequest |
| fetchGlobal() | Fetches one or more items from a global, like cookies, get, post, etc. | Request |
| getBody() | Returns the Message's body. | Message |
| getCookie() | Fetch an item from the COOKIE array. | IncomingRequest |
| getDefaultLocale() | Returns the default locale as set in Config\App.php | IncomingRequest |
| getEnv() | Fetch an item from the $_ENV array. | Request |
| getFile() | Retrieves a single file by the name of the input field used to upload it. | IncomingRequest |
| getFileMultiple() | Verify if a file exist, by the name of the input field used to upload it, in the collection of uploaded files and if is have been uploaded with multiple option. | IncomingRequest |
| getFiles() | Returns an array of all files that have been uploaded with this request. Each file is represented by an UploadedFile instance. | IncomingRequest |
| getGet() | Fetch an item from GET data. | IncomingRequest |
| getGetPost() | Fetch an item from GET data with fallback to POST. | IncomingRequest |
| getHeader() | Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects. | Message |
| getHeaderLine() | Retrieves a comma-separated string of the values for a single header. | Message |
| getHeaders() | Returns an array containing all headers. | Message |
| getIPAddress() | Gets the user's IP address. | Request |
| getJSON() | A convenience method that grabs the raw input stream and decodes the JSON into an array. | IncomingRequest |
| getLocale() | Gets the current locale, with a fallback to the default locale if none is set. | IncomingRequest |
| getMethod() | Get the request method. | Request |
| getOldInput() | Attempts to get old Input data that has been flashed to the session with redirect_with_input(). It first checks for the data in the old POST data, then the old GET data and finally check for dot arrays | IncomingRequest |
| getPost() | Fetch an item from POST. | IncomingRequest |
| getPostGet() | Fetch an item from POST data with fallback to GET. | IncomingRequest |
| getProtocolVersion() | Returns the HTTP Protocol Version. | Message |
| getRawInput() | A convenience method that grabs the raw input stream(send method in PUT, PATCH, DELETE) and decodes the String into an array. | IncomingRequest |
| getServer() | Fetch an item from the $_SERVER array. | Request |
| getUserAgent() | Fetch the user agent string | IncomingRequest |
| getVar() | Fetch an item from the $_REQUEST object. This is the simplest way to grab data from the request object and can be used in lieu of the other get* methods in most cases. | IncomingRequest |
| hasHeader() | Determines whether a header exists. | Message |
| isAJAX() | Test to see if a request contains the HTTP_X_REQUESTED_WITH header. | IncomingRequest |
| isCLI() | Determines if this request was made from the command line (CLI). | IncomingRequest |
| isSecure() | Attempts to detect if the current connection is secure through a few different methods. | IncomingRequest |
| isValidIP() | Validate an IP address | Request |
| negotiate() | Provides a convenient way to work with the Negotiate class for content negotiation. | IncomingRequest |
| populateHeaders() | Populates the $headers array with any headers the getServer knows about. | Message |
| prependHeader() | Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess) | Message |
| removeHeader() | Removes a header from the list of headers we track. | Message |
| setBody() | Sets the body of the current message. | Message |
| setGlobal() | Allows manually setting the value of PHP global, like $_GET, $_POST, etc. | Request |
| setHeader() | Sets a header and it's value. | Message |
| setLocale() | Sets the locale string for this request. | IncomingRequest |
| setMethod() | Sets the request method. Used when spoofing the request. | Request |
| setProtocolVersion() | Sets the HTTP protocol version. | Message |
Constructor
| Parameter Name | Type | Description |
|---|---|---|
| $config | object | |
| $uri | \CodeIgniter\HTTP\URI | |
| $body | string|null | |
| $userAgent | \CodeIgniter\HTTP\UserAgent |
Returns:
Appends data to the body of the current message.
| Parameter Name | Type | Description |
|---|---|---|
| $data | ||
| $data |
Returns: \Message|\Response
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string |
Returns: \Message
Handles setting up the locale, perhaps auto-detecting through content negotiation.
| Parameter Name | Type | Description |
|---|---|---|
| $config | ||
| $config |
Returns:
Based on the URIProtocol Config setting, will attempt to detect the path portion of the current URI.
| Parameter Name | Type | Description |
|---|---|---|
| $protocol | string |
Returns: string
Fetches one or more items from a global, like cookies, get, post, etc.
Can optionally filter the input when you retrieve it by passing in a filter.
If $type is an array, it must conform to the input allowed by the filter_input_array method.
http://php.net/manual/en/filter.filters.sanitize.php
| Parameter Name | Type | Description |
|---|---|---|
| $method | string | Input |
| $index | string|array|null | |
| $filter | int|null | Filter |
| $flags | mixed |
Returns: mixed
Returns the Message's body.
Returns: mixed
Fetch an item from the COOKIE array.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | Index |
| $filter | int|null | A |
| $flags | mixed |
Returns: mixed
Returns the default locale as set in Config\App.php
Returns: string
Fetch an item from the $_ENV array.
| Parameter Name | Type | Description |
|---|---|---|
| $index | null | Index |
| $filter | null | A |
| $flags | null |
Returns: mixed
Retrieves a single file by the name of the input field used to upload it.
| Parameter Name | Type | Description |
|---|---|---|
| $fileID | string |
Returns: \UploadedFile|null
Verify if a file exist, by the name of the input field used to upload it, in the collection of uploaded files and if is have been uploaded with multiple option.
| Parameter Name | Type | Description |
|---|---|---|
| $fileID | string |
Returns: array|null
Returns an array of all files that have been uploaded with this request. Each file is represented by an UploadedFile instance.
Returns: array
Fetch an item from GET data.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | Index |
| $filter | int|null | A |
| $flags | mixed|null |
Returns: mixed
Fetch an item from GET data with fallback to POST.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | Index |
| $filter | int|null | A |
| $flags | mixed |
Returns: mixed
Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: array|\CodeIgniter\HTTP\Header
Retrieves a comma-separated string of the values for a single header.
This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.
NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: string
Returns an array containing all headers.
Returns: array An array of the request headers
Gets the user's IP address.
Returns: string IP address
A convenience method that grabs the raw input stream and decodes the JSON into an array.
If $assoc == true, then all objects in the response will be converted to associative arrays.
| Parameter Name | Type | Description |
|---|---|---|
| $assoc | bool | Whether |
| $depth | int | How |
| $options | int | Bitmask |
Returns: mixed
Gets the current locale, with a fallback to the default locale if none is set.
Returns: string
Get the request method.
| Parameter Name | Type | Description |
|---|---|---|
| $upper | bool | Whether |
Returns: string
Attempts to get old Input data that has been flashed to the session with redirect_with_input(). It first checks for the data in the old POST data, then the old GET data and finally check for dot arrays
| Parameter Name | Type | Description |
|---|---|---|
| $key | string |
Returns: mixed
Fetch an item from POST.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | Index |
| $filter | int|null | A |
| $flags | mixed |
Returns: mixed
Fetch an item from POST data with fallback to GET.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | Index |
| $filter | int|null | A |
| $flags | mixed |
Returns: mixed
Returns the HTTP Protocol Version.
Returns: string
A convenience method that grabs the raw input stream(send method in PUT, PATCH, DELETE) and decodes the String into an array.
Returns: mixed
Fetch an item from the $_SERVER array.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | Index |
| $filter | int|null | A |
| $flags | null |
Returns: mixed
Fetch the user agent string
Returns: \CodeIgniter\HTTP\UserAgent
Fetch an item from the $_REQUEST object. This is the simplest way to grab data from the request object and can be used in lieu of the other get* methods in most cases.
| Parameter Name | Type | Description |
|---|---|---|
| $index | string|array|null | |
| $filter | int|null | Filter |
| $flags | mixed |
Returns: mixed
Determines whether a header exists.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: bool
Test to see if a request contains the HTTP_X_REQUESTED_WITH header.
Returns: bool
Determines if this request was made from the command line (CLI).
Returns: bool
Attempts to detect if the current connection is secure through a few different methods.
Returns: bool
Validate an IP address
| Parameter Name | Type | Description |
|---|---|---|
| $ip | string | IP |
| $which | string | IP |
Returns: bool
Provides a convenient way to work with the Negotiate class for content negotiation.
| Parameter Name | Type | Description |
|---|---|---|
| $type | string | |
| $supported | array | |
| $strictMatch | bool |
Returns: string
Populates the $headers array with any headers the getServer knows about.
Returns:
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string |
Returns: \Message
Removes a header from the list of headers we track.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: \Message
Sets the body of the current message.
| Parameter Name | Type | Description |
|---|---|---|
| $data | mixed |
Returns: \Message|\Response
Allows manually setting the value of PHP global, like $_GET, $_POST, etc.
| Parameter Name | Type | Description |
|---|---|---|
| $method | string | |
| $value | ||
| $value |
Returns: $this
Sets a header and it's value.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | array|null|string |
Returns: \Message|\Response
Sets the locale string for this request.
| Parameter Name | Type | Description |
|---|---|---|
| $locale | string |
Returns: \IncomingRequest
Sets the request method. Used when spoofing the request.
| Parameter Name | Type | Description |
|---|---|---|
| $method | string |
Returns: \Request
Sets the HTTP protocol version.
| Parameter Name | Type | Description |
|---|---|---|
| $version | string |
Returns: \Message